using System;
using System.Collections;

namespace Sedna.Core.Controller
{
	/// <summary>
	/// Summary description for NestedExceptionHandlerMatcher.
	/// </summary>
	public class NestedExceptionHandlerMatcher: SuperTypeBasedExceptionHandlerMatcher
	{
		public override IExceptionHandler Match(Exception exception)
		{
			return Match(exception, ExceptionHandlers);
		}

		public override IExceptionHandler Match(Exception exception, IList exceptionHandlers)
		{
			IExceptionHandler handler=null;
			do
			{
				if (exception==null)
				{
					return null;
				}
				handler=base.Match(exception, exceptionHandlers);
				exception=exception.InnerException;
			} while (handler==null);
			return handler;
		}

	}
}
